import { defineStore } from "pinia";
import router from "../../../router";

export const useAppStore = defineStore('app', {
    state: (): any => ({
        navTitle: '首页',
        navBg: '',
        navLeftText: '',
        navLeftArrow: false,
        navRightText: '',
        navLeftClick: () => { },
        navRightClick: () => { },
        activeIndex: 0,
    }),
    actions: {
        setAppNav(label, value) {
            this[label] = value
        },
        resetAppNav() {
            this.navTitle = '';
            this.navBg = '';
            this.navLeftText = '';
            this.navLeftArrow = false;
            this.navRightText = '';
            this.navLeftClick = () => { router.go(-1) };
            this.navRightClick = () => { };
        },

        updateActiveIndex(val) {
            this.activeIndex = val;
        },

        resetApp() {
            this.$reset()
        }
    }
})